﻿ 

//-------------页面初始化--------------
function initPage()
{
    on_query();  
} 

//-------------查询-----------
function on_query()
{ 	
	CleanConfig(); //清空配置  
  
	AddItemConfig("name", 0);		//    
	AddItemConfig("alias", 0);		//别名  
	AddItemConfig("module", 0);		//模块名  
	AddItemConfig("gold", 0);		//金币
	AddItemConfig("money", 0);		//金币
	AddItemConfig("exp", 0);		//经验值
	AddItemConfig("charm", 0);		//魅力增减
	AddItemConfig("courage", 0);	//勇气值 
	AddItemConfig("power", 0);	    //体力值 
	AddItemConfig("energy", 0);		//精力(人缘)(关注人数) 
	AddItemConfig("quality", 0); 	//人品值 
	AddItemConfig("other", 0); 		//其它 
	AddItemConfig("remark", 0); 	//备注
	 
	AddItemConfig("name", 2, "selectItem", "编辑");
	AddItemConfig("name", 2, "deleteFunc", "删除");
	
	SetPagingConfig("paging_sys_config", "get_config_logic_total", "", 
					"paging_sys_config", "get_config_logic_list", "");
					
	//PagingInit(GetDefaultPageCount(), "tbody_query", "div_paging");            
	PagingInit(10, "tbody_query", "div_paging");            
}

//--删除
function deleteFunc(index, id)
{ 
	alert("不允许删除");
	return;
	if(confirm("是否删除?") == false) return;
	
	var data = "&name=" + id; 
	PostToPHP(__deleteFuncCallback, "sys_config", "delete_config_logic", data);
}
function __deleteFuncCallback(text)
{
	// alert(text); 
	var jsonObj = String2JSON(text);            
	ShowReturnMsg(jsonObj, RePaging);
} 
//编辑
function selectItem(index, id)
{ 	
	var data = "&name=" + id; 
	PostToPHP(__selectItemCallback, "sys_config", "select_config_logic", data);
}
function __selectItemCallback(text)
{
	//alert(text); 
	var jsonObj = String2JSON(text);
	var ds = GetDataSet(jsonObj);
 	if(jsonObj && ds[0])
    {   
        var items = ds[0];  
        
		for(var name in items)
		{ 
			tmpObj = $(name);   
			if(tmpObj)
			{	
				//alert(tmpObj);
				tmpObj.value = items[name];
			}
		}
	}
} 

//-------------新增, 修改-----------
function _getCtrlVal(strID)
{
	tmpObj = $(strID);
	if(tmpObj && tmpObj.value) 
		return tmpObj.value; 
	else 
		return "";
}
function onclick_edit_config_logic()
{		
	var data = "name=" + _getCtrlVal("name"); 
	data += "&alias=" + _getCtrlVal("alias"); 
	data += "&module=" + _getCtrlVal("module"); 
	data += "&gold=" + _getCtrlVal("gold"); 
	data += "&money=" + _getCtrlVal("money"); 
	data += "&exp=" + _getCtrlVal("exp"); 
	data += "&charm=" + _getCtrlVal("charm"); 
	data += "&courage=" + _getCtrlVal("courage"); 
	data += "&power=" + _getCtrlVal("power"); 
	data += "&energy=" + _getCtrlVal("energy"); 
	data += "&quality=" + _getCtrlVal("quality"); 
	data += "&other=" + _getCtrlVal("other"); 
	data += "&remark=" + _getCtrlVal("remark");  
	PostToPHP(__onclickEditConfigLevelCallback, "sys_config", "edit_config_logic", data);
}
function __onclickEditConfigLevelCallback(text)
{
	//alert(text); 
	var jsonObj = String2JSON(text);            
	ShowReturnMsg(jsonObj, RePaging);
} 